//
//  PywInputTF.m
//  PywSdk
//
//  Created by liangyidong on 16/3/2.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "PywInputTF.h"

@implementation PywInputTF

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.clearButtonMode = UITextFieldViewModeWhileEditing;
        self.keyboardType = UIKeyboardTypeASCIICapable;
        self.autocapitalizationType = UITextAutocapitalizationTypeNone;
        self.borderStyle = UITextBorderStyleNone;
        [self setTintColor:[UIColor lightGrayColor]];
        self.leftViewMode = UITextFieldViewModeAlways;
    }
    return self;
}

- (void)setPlaceholder:(NSString *)placeholder{
    NSMutableAttributedString *attrPlaceHolder = [[NSMutableAttributedString alloc] initWithString:placeholder];
    self.tintColor = [UIColor lightGrayColor];
    [attrPlaceHolder addAttributes:@{
                                     NSForegroundColorAttributeName:[UIColor lightGrayColor],
                                     NSFontAttributeName: [UIFont systemFontOfSize:13]
                                     }range:NSMakeRange(0, attrPlaceHolder.length)];
    self.attributedPlaceholder = attrPlaceHolder;
}

- (CGRect)leftViewRectForBounds:(CGRect)bounds{
    CGRect rect = [super leftViewRectForBounds:bounds];
    CGFloat rightViewY = (40 - rect.size.height) / 2.0;
    CGFloat rightViewX = rect.origin.x + 5;
    return CGRectMake(rightViewX, rightViewY, rect.size.width, rect.size.height);
}

- (CGRect)rightViewRectForBounds:(CGRect)bounds{
    CGRect rect = [super rightViewRectForBounds:bounds];
    CGFloat rightViewY = (40 - rect.size.height) / 2.0;
    CGFloat rightViewX = rect.origin.x - 5;
    return CGRectMake(rightViewX, rightViewY, rect.size.width, rect.size.height);
}


@end
